{%extends "base.html"%}
{%block body%}
<script type="text/javascript" src="/static/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
   
	$(document).ready(function(){
		$("#formEdit").validate({
			rules:{
				"title": "required"
				,"cate":"required"
				,"link": "url"
			}
		});
		CKEDITOR.replace( 'contentArticle' );
		$('#status').val('{{item.status}}');
		$('#cate').val('{{item.cate.key.id}}');
		if($('#link').val()=='None')
			$('#link').val('');
		if($('#cate').val()=='')
			$('#cate').val('1031');	//girl
	});
	function OnSubmit()
	{
		var contentArticle = CKEDITOR.instances.content.getData();
		$('#formEdit #contentArticle').val(contentArticle);
		$('#formEdit').submit();
	}
		
</script>
<table cellpadding="2" width="100%" class="smallfont" border="0">
  <tr>
  	<td class="errorlist" >{{err}}</td>
  </tr>
</table> 
<form name="formEdit" id="formEdit" action="" method="post" onsubmit="OnSubmit();" enctype='multipart/form-data'>
<table border="0" cellpadding="5" cellspacing="0" width=100%  style="text-align:left">
{% if item.image %}
	<tr> <td colspan="2" align="center"><img title="image" width="150" src='/varticle/image/{{item.key.id}}'></td></tr>
{% endif %}
<tr>
	<th width="150">Title*</th>
</tr>
<tr>	
	<td><input name="title" id="title" type="text" size="80" value="{{item.title}}" ></td>
</tr>
<tr>
	<th>Category*</th>
</tr>
<tr>	
	<td>
		<select id="cate" name="cate">
			<option value="">Root</option>
			{% for cate in optionCate.items%}
			<option value="{{cate.1.value}}">{{cate.1.key}}</option>
			{% endfor%}
		</select>
	</td>
</tr>
<!--<tr>
	<th>Hình</th>
	<td><input type='file' name='image'>
	
	</td>
</tr>
<tr>
	<th>Link (http://...)</th>
	<td><input type="text" id="link" name="link" size="80"  value="{{item.link}}" /></td>
</tr>
-->
<!--<tr >
	<th>Status</th>
	<td>
		<select name="status" id="status">
			<option value="1">Hide</option>
			<option value="1">Show</option>
		</select>
 	</td>
</tr>
-->
<tr>
	<th valign="top">Description</th>
</tr>
<tr>	
	<td><textarea cols="60" rows="5"  name="scontent" id="scontent">{{item.scontent}}</textarea></td>
</tr>
<tr>
	<th valign="top">Content</th>
</tr>
<tr>	
	<td><textarea cols="60" rows="20"  name="content" id="contentArticle">{{item.content}}</textarea></td>
</tr>
<tr>
	<td align="center"><input type="submit" value="Send"></td>
</tr>

</table>
<br><br>

<br><br>
</form>
{%endblock%}